package com.sfeir.gwt.webding.client.showcase;

import java.util.List;

import com.google.gwt.event.logical.shared.ValueChangeEvent;
import com.google.gwt.event.logical.shared.ValueChangeHandler;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sfeir.gwt.webding.client.component.Info;
import com.sfeir.gwt.webding.client.component.label.LabelComboBox;
import com.sfeir.gwt.webding.client.component.label.LabelMultiSuggestBox;
import com.sfeir.gwt.webding.client.component.label.LabelSuggestBox;
import com.sfeir.gwt.webding.client.showcase.ShowcaseAnnotations.ShowcaseSource;


public class TabSuggestBox extends LazyTab {
    /**
     * 
     */
    @ShowcaseSource
    protected Widget createTab() {
        VerticalPanel panel = new VerticalPanel();

        LabelSuggestBox field1 = new LabelSuggestBox("Champs SuggestBox", true);
        field1.addItems(listWords);
        field1.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field1);

        LabelComboBox<String> field2 = new LabelComboBox<String>("Champs ComboBox", true);
        field2.addItems(listDepartement);
        field2.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field2);

        LabelSuggestBox field3 = new LabelSuggestBox("Champs SuggestBox avec valeur par défaut", true);
        field3.addItems(listDepartement);
        field3.addDefaultItem("Entrez le nom d'un département français");
        field3.addDefaultItem("Pour avoir la liste");
        field3.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field3);

        LabelSuggestBox field4 = new LabelSuggestBox("Champs SuggestBox recherche début des mots", true);
        field4.setFullTextSearch(false);
        field4.addItems(listDepartement);
        field4.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field4);

        LabelMultiSuggestBox field5 = new LabelMultiSuggestBox("Champs SuggestBox multiple (séparé par une virgule)");
        field5.setFullTextSearch(false);
        field5.addItems(listWords);
        field5.addValueChangeHandler(new ValueChangeHandler<List<String>>() {
            public void onValueChange(ValueChangeEvent<List<String>> event) {
                Info.display("Nouvelle valeur : " + event.getValue());
            }
        });
        panel.add(field5);

        return panel;
    }

    @Override
    public String getDescription() {
        return "Champs de saisie avec autocomplétion";
    }

    @Override
    public String getName() {
        return "Champs SuggestBox";
    }
}
